package 剑指Offer;

public class Offer05_替换空格 {
    public String replaceSpace(String s) {
        StringBuilder res = new StringBuilder();

        for (char item : s.toCharArray()) {
            if (item == ' ') {
                res.append("%20");
            }else{
                res.append(item);
            }
        }

        return res.toString();

        // return s.replace(" ","%20");  直接用库函数
    }
}
